package com.yazi.mxz.job.controller;

import javax.annotation.Resource;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myframework.smhj.jackson.result.StatusResult;
import com.yazi.mxz.common.entity.beans.StorePromote;
import com.yazi.mxz.job.quartz.StorePromoteEndJob;
import com.yazi.mxz.job.quartz.StorePromoteStartJob;

@Controller("storePromoteController")
@RequestMapping("/storePromote")
public class StorePromoteController {

	private static Logger log = LoggerFactory.getLogger(StorePromoteController.class);

	@Resource
	StorePromoteStartJob storePromoteStartJob;
	@Resource
	StorePromoteEndJob storePromoteEndJob;

	@RequestMapping
	@ResponseBody
	public StatusResult index(@RequestBody StorePromote storePromote) {
		log.debug("远程请求更新店铺促销信息状态");
		StatusResult jsonResult = new StatusResult();
		try {
			storePromoteStartJob.checkDoit(storePromote.getStartTime());
			storePromoteEndJob.checkDoit(storePromote.getEndTime());
			jsonResult.setOkMessage("ok");
		} catch (Exception e) {
			log.warn("更新店铺促销信息状态异常: ", e);
			jsonResult.setErrorMessage(e.getMessage());
		}
		return jsonResult;
	}

}
